package com.cheng.controller;

import com.cheng.common.results.DataRslt;
import com.cheng.data.vo.CompanyMoveInfVO;
import com.cheng.data.vo.ReqPageInfoVO;
import com.cheng.data.vo.RespPageInfoVO;
import com.cheng.operation.CompanyInfoOperation;
import com.cheng.operation.CompanyMoveInfOperation;
import org.apache.logging.log4j.core.appender.rolling.action.IfFileName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author: ChengJW
 * @date: 2021/12/8 8:07
 * @version: 1.0
 * @description: 档案库房菜单处理类
 */
@Controller
public class ArchivesKuFangController extends BaseController{

    private final static Logger log = LoggerFactory.getLogger(ArchivesKuFangController.class);

    @Autowired
    private CompanyInfoOperation companyInfoOperation;

    @Autowired
    private CompanyMoveInfOperation companyMoveInfOperation;

    @RequestMapping("/archivesKuFang/archivesMove")
    public String archivesMove(){
        return "archivesMove";
    }

    @RequestMapping("/archivesKuFang/archivesMove/archivesMoveOut")
    public String archivesMoveOut(){
        return "archivesMoveOut";
    }

    @RequestMapping("/archivesKuFang/archivesMove/archivesMoveIn")
    public String archivesMoveIn(){
        return "archivesMoveIn";
    }

    @RequestMapping("/archivesMoveOut/showCompanyInfo")
    public String showComapnyInfoList(){
        return  "showCompanyInfo";
    }

    /**
    * @author: ChengJW
    * @params: []
    * @return: com.cheng.common.results.DataRslt
    * @date: 2021/12/15
    * @description: 档案迁出列表查询
    */
    @RequestMapping("/archivesMoveOut/queryArchivesMoveOutList")
    @ResponseBody
    public DataRslt queryArchivesMoveOutList(ReqPageInfoVO pageInfoVO){
        pageInfoVO.setUserCode(getUrCode());
        RespPageInfoVO respPageInfoVO = companyInfoOperation.queryArchivesMoveList(pageInfoVO);
        if (respPageInfoVO != null){
            return tabSuccess(respPageInfoVO);
        }
        return tabFailure();
    }

    /**
    * @author: ChengJW
    * @params: []
    * @return: com.cheng.common.results.DataRslt
    * @date: 2021/12/16
    * @description: 根据统一社会信用代码查询企业信息
    */
    @RequestMapping("/showCompanyInfo/queryArchivesInfoListByCreditCode")
    @ResponseBody
    public DataRslt queryArchivesInfoListByCreditCode(ReqPageInfoVO pageInfoVO){

        pageInfoVO.setUserCode(getUrCode());
        RespPageInfoVO respPageInfoVO = companyInfoOperation.queryCompanyInfoList(pageInfoVO);
        if (respPageInfoVO != null){
            return tabSuccess(respPageInfoVO);
        }
        return tabFailure();
    }

    /**
    * @author: ChengJW
    * @params: [vo]
    * @return: com.cheng.common.results.DataRslt
    * @date: 2021/12/18
    * @description: 企业迁出
    */
    @RequestMapping("/archivesMoveOut/moveOut")
    @ResponseBody
    public DataRslt archivesMoveOut(CompanyMoveInfVO vo){
        companyMoveInfOperation.insertCompanyMoveInf(vo);
        return success();
    }

    /**
    * @author: ChengJW
    * @params: [pageInfoVO]
    * @return: com.cheng.common.results.DataRslt
    * @date: 2021/12/18
    * @description: 档案迁入列表
    */
    @RequestMapping("/archivesMoveOut/queryArchivesMoveInList")
    @ResponseBody
    public DataRslt queryArchivesMoveInList(ReqPageInfoVO pageInfoVO){
        pageInfoVO.setUserCode(getUrCode());
        RespPageInfoVO respPageInfoVO = companyMoveInfOperation.queryCompanyMoveList(pageInfoVO);
        return tabSuccess(respPageInfoVO);
    }

    @RequestMapping("/archivesMoveOut/moveIn")
    @ResponseBody
    public DataRslt archivesMoveIn(CompanyMoveInfVO vo){
        vo.setCmMvInCode(getUrCode());
        companyMoveInfOperation.updateCompanyMoveInf(vo);
        return success();
    }
}
